# 主动合约策略
from loguru import logger

zd_strategy = {
    # 合约的总最大下单量
    "max_volume": 5,
    # 开仓价差
    "open_spread": 25,
    # 开仓量，成交后相减，平仓后相加
    "open_volume": 5,
    # 平仓价差
    "close_spread": 60,
    # 平仓量，开仓成交后相加，平仓成交后相减
    "close_volume": 0,
}
# 主动合约策略
bd_strategy = {
    "max_volume": 100,
    "target_volume": 10
}


def zd_open_spread():
    return zd_strategy['open_spread']


def zd_open_volume():
    return zd_strategy['open_volume']


def zd_close_spread():
    return zd_strategy['close_spread']


def zd_close_volume():
    return zd_strategy['close_volume']


def update_zd_left_volume(volume, offset):
    zd_strategy['open_volume'] -= volume if offset == "OPEN" else -volume
    zd_strategy['close_volume'] -= volume if offset == "CLOSE" else -volume

    logger.info("S1策略总可下单量{0}，可开量{1}，可平量{2}", zd_strategy['max_volume'], zd_strategy['open_volume'], zd_strategy['close_volume'])
